package com.qf.business.message.handler;

import com.qf.business.course.feign.CourseFeign;
import com.qf.business.message.entity.Message;
import com.qf.business.message.handler.base.BaseMsgChannelHandler;
import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * author Ken
 * create_time 2023/1/6
 */
@Component
@ChannelHandler.Sharable
public class BaseCloseMsgChannelHandler extends BaseMsgChannelHandler {

    @Autowired
    private CourseFeign courseFeign;

    @Override
    protected String action() {
        return "close";
    }

    @Override
    protected void handler(ChannelHandlerContext ctx, Message msg) {
        Long cid = msg.getCid();
        //通知课程服务器修改课程状态
        courseFeign.updateCourseStatus(cid, 0);
    }
}
